package pers.xuehongyan.useat.server.enity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

/**
 * @author xuehongyan
 */
@Data
@TableName("machine")
public class Machine {
    @TableId(value = "id", type = IdType.AUTO)
    Integer id;

    @TableField("active")
    Boolean active;

    @TableField("size")
    Integer size;

    @TableField("capacity")
    Integer capacity;

    public Machine() {
        this.size = 0;
        this.active = false;
    }

    public Machine(Integer capacity) {
        this();
        this.capacity = capacity;
    }

    public boolean isFull() {
        return size >= capacity;
    }

    public boolean isEmpty() {
        return size.equals(0);
    }

    public void increase() {
        size++;
    }

    public void decrease() {
        size--;
    }
}
